package com.bbcare.treat.plat.service.impl;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bbcare.comm.AppException;
import com.bbcare.comm.Constants;
import com.bbcare.comm.DateUtil;
import com.bbcare.comm.ErrorCode;
import com.bbcare.comm.SeqUtil;
import com.bbcare.comm.ToolUtils;
import com.bbcare.followup.plat.entity.FollowQueue;
import com.bbcare.followup.plat.entity.Patient;
import com.bbcare.followup.plat.service.IFollowQueueService;
import com.bbcare.followup.plat.service.IPatientService;
import com.bbcare.followup.plat.store.ibatis.IPatientDAO;
import com.bbcare.treat.plat.service.IDealWithEyesCreate;
import com.bbcare.treat.plat.service.IPatientArchService;
import com.bbcare.treat.plat.service.IPatientTreatService;
import com.bbcare.treat.plat.service.IPtTaskTreatService;

@Service
public class DealWithEyesCreate implements IDealWithEyesCreate{
	private final Log logger = LogFactory.getLog(DealWithEyesCreate.class);

	@Autowired
	private IPatientDAO patientDao;

	@Autowired
	private IPatientArchService patientArchService;

	@Autowired
    private IFollowQueueService followQueueSerivce;

	@Autowired
    private IPatientTreatService patientTreatService;

	@Autowired
    private IPtTaskTreatService ptTaskTreatService;

    @Autowired
    private IPatientService patientSerivce;

	public  Map<String, Object> readExcel(HSSFWorkbook workbook,int sheetInt,String fileName, Map<String, Object> argMap) throws Exception {
		Map<String,Object> mapIn = new HashMap<String,Object>();
		Map<String,Object> oprInfo = new HashMap<String,Object>();
		String queueId = checkQueue(fileName);
		oprInfo.put("queueId", queueId);
		if(StringUtils.isBlank(queueId)) {
			return null ;
		}
		Map<String, Object> varpd = new LinkedHashMap<String, Object>();
		try {
			HSSFSheet sheet = workbook.getSheetAt(sheetInt); // sheet 从0开始
			int rowNum = sheet.getLastRowNum();// 获得总行数
			for (int i = 2; i < rowNum; i++) { // 行循环开始
				Map<String,Object> map = new HashMap<String,Object>();
				HSSFRow row = sheet.getRow(i); // 行
				if (row == null)
				// 中间如果有空行，跳过
				continue;
				// 列循环开始
				int coloumNum = sheet.getRow(i).getLastCellNum();
				for (int j = 0; j < coloumNum; j++) {
					HSSFCell cell = row.getCell(j);
					//如果号码为空，则
					if(j==0) {
						String value = dealWithHSSF(cell);
						if(StringUtils.isBlank(value)) {
							break;
						}
					}
					if(fileName.indexOf("斜视") !=-1) {
						//处理数据
						createxsArchive(map,j,cell,sheetInt);
					}else if(fileName.indexOf("白内障") !=-1) {
						createxsArchiveAataract(map,j,cell,sheetInt);
					}
				}

				String userName = dealWithHSSF(row.getCell(1));
				if(StringUtils.isBlank(userName)) {
					continue;
				}
				String phoneNo = dealWithHSSF(row.getCell(0));
				String userStatus = "1";
				argMap.put("userName",userName);
				argMap.put("phoneNo",phoneNo);
				argMap.put("userStatus",userStatus);
				String patientId = "";
				String ptSchemeId = "";
				//处理数据，拼接不存在的变量值
				if(fileName.indexOf("斜视") !=-1) {
					if(0==sheetInt) {
						fillMassage(map,row);
						NewArchive(mapIn,fileName);
					}else if(1==sheetInt) {
						fillAataractBefore(map,row);
						NewTask(mapIn,oprInfo,fileName,sheetInt);
					}else if(2==sheetInt) {
						fillAataractMiddle(map,row);
						NewTask(mapIn,oprInfo,fileName,sheetInt);
					}else if(3==sheetInt) {
						fillAataractAfter(map,row);
						NewTask(mapIn,oprInfo,fileName,sheetInt);
					}
				}else if(fileName.indexOf("白内障") !=-1) {
					//处理数据，拼接不存在的变量值
					if(0==sheetInt) {
						fillMassageAataract(map,row);
						NewArchive(mapIn,fileName);
					}else if(1==sheetInt) {
						fillAataractbnzBefore(map,row);
						NewTask(mapIn,oprInfo,fileName,sheetInt);
					}else if(2==sheetInt) {
						fillAataractbnzMiddle(map,row);
						NewTask(mapIn,oprInfo,fileName,sheetInt);
					}else if(3==sheetInt) {
						fillAataractbnzAfter(map,row);
						NewTask(mapIn,oprInfo,fileName,sheetInt);
					}
				}
				if(sheetInt>0&&sheetInt<4) {
					List<Map<String,Object>> list  =  patientDao.selectPtSchemeAndPatientByPhoneAndQueueId(argMap);
					if(CollectionUtils.isEmpty(list)) {
						continue;
					}
					Map<String,Object> mapOut = list.get(0);
					patientId = (String) mapOut.get("id");
					ptSchemeId = (String) mapOut.get("ptSchemeId");
					oprInfo.put("patientId", patientId);
					oprInfo.put("ptSchemeId", ptSchemeId);
					mapIn.put("oprInfo", oprInfo);
				}
				mapIn.put("questiones", map);
				if(0==sheetInt) {
					modifyMassage(mapIn,argMap);
				}else {
					modifyTask(mapIn,argMap);
				}

			}
			workbook.close();
		} catch (Exception e) {
			throw e;
		}
		return varpd;
	}




	public  Map<String, Object> readExcelXSSF(XSSFWorkbook workbook,int sheetInt,String fileName, Map<String, Object> argMap) throws Exception {
		Map<String,Object> mapIn = new HashMap<String,Object>();
		Map<String,Object> oprInfo = new HashMap<String,Object>();
		Map<String, Object> varpd = new LinkedHashMap<String, Object>();
		try {
			XSSFSheet sheet = workbook.getSheetAt(sheetInt); // sheet 从0开始
			int rowNum = sheet.getLastRowNum();// 获得总行数
			for (int i = 0; i < rowNum; i++) { // 行循环开始
				Map<String,Object> map = new HashMap<String,Object>();
				XSSFRow row = sheet.getRow(i); // 行
				if (row == null)
					break; // 中间如果有空行，则退出
				int coloumNum = sheet.getRow(i).getLastCellNum();
				for (int j = 0; j < coloumNum; j++) {
					XSSFCell cell = row.getCell(j);
					//如果号码为空，则
					if(j==0) {
						String value = dealWithXSSF(cell);
						if(StringUtils.isBlank(value)) {
							break;
						}
					}
					//处理数据
					if(fileName.indexOf("斜视") !=-1) {
						//处理数据
						createxsArchive(map,j,cell,sheetInt);
					}else if(fileName.indexOf("白内障") !=-1) {
						createxsArchiveAataract(map,j,cell,sheetInt);
					}
				}
				String userName = dealWithXSSF(row.getCell(1));
				if(StringUtils.isBlank(userName)) {
					continue;
				}
				String phoneNo = dealWithXSSF(row.getCell(0));
				String userStatus = "1";
				argMap.put("userName",userName);
				argMap.put("phoneNo",phoneNo);
				argMap.put("userStatus",userStatus);
				String patientId = "";
				String ptSchemeId = "";
				//处理数据，拼接不存在的变量值
				if(fileName.indexOf("斜视") !=-1) {
					if(0==sheetInt) {
						fillMassage(map,row);
						NewArchive(mapIn,fileName);
					}else if(1==sheetInt) {
						fillAataractBefore(map,row);
						NewTask(mapIn,oprInfo,fileName,sheetInt);
					}else if(2==sheetInt) {
						fillAataractMiddle(map,row);
						NewTask(mapIn,oprInfo,fileName,sheetInt);
					}else if(3==sheetInt) {
						fillAataractAfter(map,row);
						NewTask(mapIn,oprInfo,fileName,sheetInt);
					}
				}else if(fileName.indexOf("白内障") !=-1) {
					//处理数据，拼接不存在的变量值
					if(0==sheetInt) {
						fillMassageAataract(map,row);
						NewArchive(mapIn,fileName);
					}else if(1==sheetInt) {
						fillAataractbnzBefore(map,row);
						NewTask(mapIn,oprInfo,fileName,sheetInt);
					}else if(2==sheetInt) {
						fillAataractbnzMiddle(map,row);
						NewTask(mapIn,oprInfo,fileName,sheetInt);
					}else if(3==sheetInt) {
						fillAataractbnzAfter(map,row);
						NewTask(mapIn,oprInfo,fileName,sheetInt);
					}
				}
				if(sheetInt>0&&sheetInt<4) {
					List<Map<String,Object>> list  =  patientDao.selectPtSchemeAndPatientByPhoneAndQueueId(argMap);
					if(CollectionUtils.isEmpty(list)) {
						continue;
					}
					Map<String,Object> mapOut = list.get(0);
					patientId = (String) mapOut.get("id");
					ptSchemeId = (String) mapOut.get("ptSchemeId");
					oprInfo.put("patientId", patientId);
					oprInfo.put("ptSchemeId", ptSchemeId);
					mapIn.put("oprInfo", oprInfo);
				}
				mapIn.put("questiones", map);
				if(0==sheetInt) {
					modifyMassage(mapIn,argMap);
				}else {
					modifyTask(mapIn,argMap);
				}
			}
			workbook.close();
		} catch (Exception e) {
			throw e;
		}
		return varpd;
	}

	public static String dealWithXSSF(XSSFCell cell) {
		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
		String outString = "";
		if (cell == null) {
			return outString;
		} else {
			// 判断单元格的数据类型
			if(XSSFCell.CELL_TYPE_NUMERIC == cell.getCellType()) {
				if (HSSFDateUtil.isCellDateFormatted(cell)) {
					outString = sf.format(cell.getDateCellValue());
					return outString;
				} else {
					if(cell.getCellStyle().getDataFormat()>0) {
						outString = sf.format(cell.getDateCellValue());
						return outString;
					}
					cell.setCellType(XSSFCell.CELL_TYPE_STRING);
				}
			}else {
				cell.setCellType(XSSFCell.CELL_TYPE_STRING);
			}
			switch (cell.getCellType()) {
			case XSSFCell.CELL_TYPE_NUMERIC: // 数字
				if (HSSFDateUtil.isCellDateFormatted(cell)) {
					outString = sf.format(cell.getDateCellValue());
				} else {
					outString = cell.getNumericCellValue()+"";
				}
				break;
			case XSSFCell.CELL_TYPE_STRING: // 字符串
				outString = cell.getStringCellValue();
				break;
			case XSSFCell.CELL_TYPE_BOOLEAN: // Boolean
				outString = cell.getBooleanCellValue() + "";
				break;
			case XSSFCell.CELL_TYPE_FORMULA: // 公式
				outString = cell.getCellFormula() + "";
				break;
			case XSSFCell.CELL_TYPE_BLANK: // 空值
				outString = "";
				break;
			case XSSFCell.CELL_TYPE_ERROR: // 故障
				outString = "";
				break;
			default:
				outString = "";
				break;
			}
		}
		return outString;

	}

	public static String dealWithHSSF(HSSFCell cell) {
		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");

		String outString = "";
		if (cell == null) {
			return outString;
		} else {
			// 判断单元格的数据类型
			if(XSSFCell.CELL_TYPE_NUMERIC == cell.getCellType()) {
				if (HSSFDateUtil.isCellDateFormatted(cell)) {
					outString = sf.format(cell.getDateCellValue());
					return outString;
				} else {
					if(cell.getCellStyle().getDataFormat()>0) {
						outString = sf.format(cell.getDateCellValue());
						return outString;
					}
					cell.setCellType(XSSFCell.CELL_TYPE_STRING);
				}
			}else {
				cell.setCellType(XSSFCell.CELL_TYPE_STRING);
			}
			switch (cell.getCellType()) {
			case XSSFCell.CELL_TYPE_NUMERIC: // 数字
				if (HSSFDateUtil.isCellDateFormatted(cell)) {
					outString = sf.format(cell.getDateCellValue());
				} else {
					outString = cell.getNumericCellValue()+"";
				}
				break;
			case XSSFCell.CELL_TYPE_STRING: // 字符串
				outString = cell.getStringCellValue();
				break;
			case XSSFCell.CELL_TYPE_BOOLEAN: // Boolean
				outString = cell.getBooleanCellValue() + "";
				break;
			case XSSFCell.CELL_TYPE_FORMULA: // 公式
				outString = cell.getCellFormula() + "";
				break;
			case XSSFCell.CELL_TYPE_BLANK: // 空值
				outString = "";
				break;
			case XSSFCell.CELL_TYPE_ERROR: // 故障
				outString = "";
				break;
			default:
				outString = "";
				break;
			}
		}
		return outString;

	}


	public static Map<String,Object> createxsArchive(Map<String,Object> map ,int j,Object cell,int count){
		String value = "";
		if(cell instanceof HSSFCell) {
			value = dealWithHSSF((HSSFCell)cell);
		}else if(cell instanceof XSSFCell) {
			value = dealWithXSSF((XSSFCell)cell);
		}
		String mapString = "";
		if(0==count) {
			mapString = "{\"0\":\"Pub1100001\",\"1\":\"Pub1100002\",\"2\":\"Pub1100003\",\"3\":\"Pub1100004\",\"4\":\"Pub12x00007\",\"5\":\"Pub12x00008\",\"7\":\"xs00002\",\"8\":\"xs00003\",\"9\":\"xs00004\",\"10\":\"xs00005\",\"11\":\"xs00006\",\"12\":\"xs00008\",\"13\":\"xs00009\",\"14\":\"xs00011\",\"15\":\"xs00012\",\"16\":\"xs00013\",\"23\":\"xs00017\",\"26\":\"xs00022\",\"27\":\"xs00023\",\"29\":\"xs00028g1\",\"30\":\"xs00029g1\",\"39\":\"xs00023g1\"}";
		}else if(1==count) {
			mapString = "{\"4\":\"Pub12x00011\",\"25\":\"xs00060\",\"26\":\"xs00061\",\"27\":\"xs00062\",\"34\":\"xspic0003g104\",\"33\":\"xspic0003g105\",\"53\":\"xs00073\",\"54\":\"xspic0004g103\",\"56\":\"Pub13x00003\",\"57\":\"Pub13x00004\",\"58\":\"Pub13x00005\",\"60\":\"xs00077\",\"61\":\"xs00078\"}";
		}else if(2==count) {
			mapString = "{\"4\":\"Pub12x00011\",\"6\":\"xs00090\",\"7\":\"xs00091\",\"8\":\"xs00092\",\"9\":\"xspic0003g104\",\"13\":\"xs00094\",\"14\":\"xs00096\",\"15\":\"xs00097\",\"16\":\"xs00098\",\"17\":\"xs00099\",\"20\":\"xs00094g1\",\"21\":\"xs00101\",\"22\":\"xs00102\",\"23\":\"xs00103\",\"24\":\"xs00104\",\"28\":\"xs00106\",\"31\":\"xs00108\"}";
		}else if(3==count) {
			mapString = "{\"4\":\"Pub12x00011\",\"24\":\"xs00129\",\"25\":\"xs00130\",\"26\":\"xs00131\",\"27\":\"xs00132\",\"34\":\"xspic00013g104\",\"33\":\"xspic00013g105\",\"36\":\"xs00154g1\",\"53\":\"xs00143\",\"54\":\"xspic0004g203\",\"56\":\"xs00144g102\",\"57\":\"xs00144g103\",\"58\":\"xs00145g102\",\"59\":\"xs00145g103\",\"60\":\"xs00145g104\",\"63\":\"xs00146g103\",\"64\":\"xs00147g102\",\"65\":\"xs00147g103\",\"66\":\"xs00147g104\",\"68\":\"Pub13x00003\",\"69\":\"Pub13x00004\",\"70\":\"Pub13x00005\",\"72\":\"xs00152\"}";
		}

		Map<String,Object> mapIn = new HashMap<String,Object>();
		mapIn = JSONObject.parseObject(mapString);
		String key= (String)mapIn.get(""+j);
		if(StringUtils.isNotBlank(key)) {
			map.put((String)mapIn.get(""+j), value);
		}
		return null;
	}


	//白内障建档信息
	public static Map<String,Object> createxsArchiveAataract(Map<String,Object> map ,int j,Object cell,int count){
		String value = "";
		if(cell instanceof HSSFCell) {
			value = dealWithHSSF((HSSFCell)cell);
		}else if(cell instanceof XSSFCell) {
			value = dealWithXSSF((XSSFCell)cell);
		}
		String mapString = "";
		if(0==count) {
			mapString = "{\"0\":\"Pub1100001\",\"1\":\"Pub1100002\",\"2\":\"Pub1100003\",\"3\":\"Pub1100004\",\"4\":\"Pub12x00007\",\"5\":\"Pub12x00008\",\"7\":\"xtbnz00001\",\"8\":\"xtbnz00002\",\"9\":\"xtbnz00003\",\"10\":\"xtbnz00004\",\"11\":\"xtbnz00005\",\"13\":\"xtbnz00006\",\"14\":\"xtbnz00007\"}";
		}else if(1==count) {
			mapString = "{\"5\":\"Pub12x00011\",\"11\":\"ttbnz00031\",\"12\":\"ttbnz00032g1\",\"13\":\"ttbnz00032g104\",\"14\":\"ttbnz00032g103\",\"15\":\"ttbnz00033g1\",\"16\":\"ttbnz00034\",\"17\":\"ttbnz00038\",\"18\":\"ttbnz00037\",\"19\":\"ttbnz00039g1\",\"20\":\"ttbnz00039g104\",\"21\":\"ttbnz00039g103\",\"22\":\"ttbnz00040g1\",\"23\":\"ttbnz00041g101\",\"24\":\"ttbnz00041g108\",\"25\":\"ttbnz00041g104\",\"26\":\"ttbnz00056\",\"27\":\"ttbnz00060\",\"28\":\"ttbnz00059\",\"29\":\"ttbnz00061\",\"30\":\"ttbnz00069\",\"31\":\"ttbnz00070\",\"32\":\"ttbnz00072g1\",\"33\":\"ttbnz00072\",\"34\":\"ttbnz00064\",\"35\":\"ttbnz00065\",\"36\":\"ttbnz00068\",\"37\":\"ttbnz00067\",\"39\":\"ttbnz00042\",\"40\":\"ttbnz00050\",\"41\":\"ttbnz00051\",\"42\":\"ttbnz00052\",\"43\":\"ttbnz00054\",\"44\":\"ttbnz00119\",\"45\":\"ttbnz00122\",\"46\":\"ttbnz00123\",\"47\":\"ttbnz00045\",\"48\":\"ttbnz00046\",\"49\":\"ttbnz00047\",\"50\":\"ttbnz00049\",\"51\":\"ttbnz00124\",\"52\":\"ttbnz00128\",\"53\":\"ttbnz00127\",\"54\":\"ttbnzCheck001g1\",\"55\":\"ttbnzCheck001g104\",\"56\":\"ttbnzCheck001g102\",\"57\":\"ttbnzCheck001g103\",\"58\":\"ttbnzCheck002g1\",\"59\":\"ttbnzCheck002g103\",\"60\":\"ttbnzCheck003g1\",\"61\":\"ttbnzCheck003g103\",\"62\":\"ttbnz114g1\",\"63\":\"ttbnz00116\",\"64\":\"ttbnzCheck004g1\",\"65\":\"ttbnzCheck004g103\",\"66\":\"ttbnzCheck005g1\",\"67\":\"ttbnzCheck005g103\",\"69\":\"Pub13x00003\",\"70\":\"Pub13x00004\",\"71\":\"Pub13x00005\",\"73\":\"ttbnz00077\",\"74\":\"ttbnz00078\"}";
		}else if(2==count) {
			mapString = "{\"4\":\"Pub12x00011\",\"6\":\"xtbnz00090\",\"7\":\"xtbnz00091\",\"8\":\"xtbnz00092\",\"9\":\"xtbnz00093\",\"10\":\"xtbnz00094\",\"12\":\"xtbnz00095g1\",\"13\":\"xtbnz00095g104\",\"14\":\"xtbnz00095g103\",\"15\":\"xtbnz00096g1\",\"16\":\"xtbnz00096g104\",\"17\":\"xtbnz00096g103\",\"18\":\"xtbnz00097g1\",\"19\":\"xtbnz00097g104\",\"20\":\"xtbnz00097g103\",\"21\":\"xtbnz00098g1\",\"22\":\"xtbnz00098g104\",\"23\":\"xtbnz00098g103\",\"24\":\"xtbnz00099\",\"26\":\"xtbnz00100\",\"35\":\"xtbnz00125g2\",\"38\":\"xtbnz00118g2\",\"39\":\"xtbnz00119g2\",\"40\":\"xtbnz00120g2\",\"53\":\"xtbnz00125g1\",\"56\":\"xtbnz00118g1\",\"57\":\"xtbnz00119g1\",\"58\":\"xtbnz00120g1\",\"63\":\"xtbnz00126\",\"64\":\"xtbnz00129\",\"65\":\"xtbnz00123g1\",\"66\":\"xtbnz00123g103\"}";
		}else if(3==count) {
			mapString = "{\"4\":\"Pub12x00011\",\"10\":\"ttbnz00140\",\"11\":\"ttbnz00144\",\"12\":\"ttbnz00143\",\"13\":\"ttbnz00152g2\",\"14\":\"ttbnz00148g1\",\"15\":\"ttbnz00152\",\"16\":\"ttbnz00151\",\"17\":\"ttbnz00153\",\"18\":\"ttbnz00157\",\"19\":\"ttbnz00156\",\"20\":\"ttbnz00158\",\"21\":\"ttbnz00164\",\"22\":\"ttbnz00161\",\"23\":\"ttbnz00167\",\"24\":\"ttbnz00171\",\"25\":\"ttbnz00170\",\"26\":\"ttbnz00172\",\"27\":\"ttbnz000173\",\"28\":\"ttbnz00174\",\"29\":\"ttbnz00182\",\"30\":\"ttbnz00183\",\"32\":\"ttbnz00185\",\"33\":\"ttbnz00177\",\"34\":\"ttbnz00178\",\"36\":\"ttbnz00180\",\"38\":\"ttbnz00213\",\"39\":\"ttbnz00221\",\"40\":\"ttbnz00222\",\"41\":\"ttbnz00223\",\"42\":\"ttbnz00225\",\"43\":\"ttbnz00230\",\"44\":\"ttbnz00233\",\"45\":\"ttbnz00234\",\"46\":\"ttbnz00216\",\"47\":\"ttbnz00217\",\"48\":\"ttbnz00218\",\"49\":\"ttbnz00220\",\"50\":\"ttbnz00235\",\"51\":\"ttbnz00238\",\"52\":\"ttbnz00128\",\"53\":\"ttbnz000187\",\"54\":\"ttbnz000188\",\"55\":\"ttbnz00194\",\"56\":\"ttbnz00198g1\",\"57\":\"ttbnz00197\",\"66\":\"ttbnzCheck007g1\",\"67\":\"ttbnzCheck007g103\",\"68\":\"ttbnzCheck008g1\",\"69\":\"ttbnzCheck008g103\",\"70\":\"ttbnz213\",\"71\":\"ttbnz00215\",\"72\":\"ttbnzCheck009g1\",\"73\":\"ttbnzCheck009g103\",\"75\":\"ttbnz00201\",\"76\":\"ttbnz00202\",\"77\":\"ttbnz00203\",\"78\":\"ttbnz00204\",\"79\":\"ttbnz00205\",\"80\":\"ttbnz00206\",\"81\":\"ttbnz00207g1\",\"82\":\"ttbnz00207g102\",\"83\":\"ttbnz00207g103\",\"84\":\"ttbnz00207g104\",\"85\":\"Pub13x00003\",\"86\":\"Pub13x00004\",\"87\":\"Pub13x00005\",\"89\":\"ttbnz00212\",}";
		}

		Map<String,Object> mapIn = new HashMap<String,Object>();
		mapIn = JSONObject.parseObject(mapString);
		String key= (String)mapIn.get(""+j);
		if(StringUtils.isNotBlank(key)) {
			map.put((String)mapIn.get(""+j), value);
		}
		return null;
	}


	public static void fillMassage(Map<String,Object> map,Object row) {
		//判断诊断斜视有无
		match(map,"xs00008","xs00006","");
		//判断遮盖有无
		match(map,"xs00011","xs00010","");
		//判断手术情况
		match(map,"xs00022","xs00020","");
		//判断全身疾病
		if(row instanceof HSSFRow) {
			map.put("xs00030g104", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(31)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("xs00030g104", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(31)))).toString());
		}
		//处理右眼屈光和左眼屈光
		map.put("xs00016g1", net.sf.json.JSONArray.fromObject(getValue(17,20,row)).toString());
		map.put("xs00016g101", net.sf.json.JSONArray.fromObject(getValue(20,23,row)).toString());
		//家族病史
		matchList(33,39,row,map,"xs00024g1","xs00022g1");
	}


	public static void fillMassageAataract(Map<String,Object> map,Object row) {
		//其他眼部疾病
		map.put("xtbnz00008", net.sf.json.JSONArray.fromObject(getValue(15,17,row)).toString());
		//其他系统疾病
		map.put("xtbnz00009", net.sf.json.JSONArray.fromObject(getValue(17,19,row)).toString());
		//家族病史
		matchList(20,26,row,map,"xtbnz00010g1","xtbnz00010g102");
		//CRYGD
		map.put("274RYVLNxOWzbom6H1Gm", net.sf.json.JSONArray.fromObject(getValueOne(28,31,row)).toString());
		//CRYGD
		map.put("27QkSn85jsKQ3mESMcSp", net.sf.json.JSONArray.fromObject(getValueOne(31,34,row)).toString());
	}


	public static void fillAataractBefore(Map<String,Object> map,Object row) {
		//裸眼视力
		map.put("xs00050", net.sf.json.JSONArray.fromObject(getValue(6,8,row)).toString());
		//矫正视力
		map.put("xs00051", net.sf.json.JSONArray.fromObject(getValue(8,10,row)).toString());
		//眼轴(mm)
		map.put("xs00052", net.sf.json.JSONArray.fromObject(getValue(10,12,row)).toString());
		//综合验光
		map.put("xs00053", net.sf.json.JSONArray.fromObject(getValue(12,14,row)).toString());
		//右眼屈光
		map.put("xs00054", net.sf.json.JSONArray.fromObject(getValue(14,17,row)).toString());
		//左眼屈光
		map.put("xs00055", net.sf.json.JSONArray.fromObject(getValue(17,20,row)).toString());
		//三棱镜度数(°)
		map.put("xs00057", net.sf.json.JSONArray.fromObject(getValue(20,22,row)).toString());
		//眼球运动
		map.put("xs00058", net.sf.json.JSONArray.fromObject(getValue(22,24,row)).toString());
		//眼部其他情况
		map.put("xs00059", net.sf.json.JSONArray.fromObject(match("",24,row,"")).toString());
		String [] arg = {"未检查","已检查"};
		matchCheck(33,row,map,"xspic0003g105","xspic0003g1",arg);
		arg = new String []{"未检查","阳性"};
		matchCheck(33,row,map,"xs00080","xs00079g1",arg);
		//角膜映光法（裸眼）
		map.put("xs00065", net.sf.json.JSONArray.fromObject(getValue(37,39,row)).toString());
		//角膜映光法(戴镜)
		map.put("xs00066", net.sf.json.JSONArray.fromObject(getValue(39,41,row)).toString());
		//三棱镜交替遮盖法(裸眼)
		map.put("xs00067", net.sf.json.JSONArray.fromObject(getValue(41,43,row)).toString());
		//三棱镜交替遮盖法(戴镜)
		map.put("xs00068", net.sf.json.JSONArray.fromObject(getValue(43,45,row)).toString());
		//三棱镜遮盖去遮盖法(裸眼)
		map.put("xs00069", net.sf.json.JSONArray.fromObject(getValue(45,47,row)).toString());
		//三棱镜遮盖去遮盖法(戴镜)
		map.put("xs00070", net.sf.json.JSONArray.fromObject(getValue(47,49,row)).toString());
		//三棱镜角膜映光法(裸眼)
		map.put("xs00071", net.sf.json.JSONArray.fromObject(getValue(49,51,row)).toString());
		//三棱镜角膜映光法(戴镜)
		map.put("xs00072", net.sf.json.JSONArray.fromObject(getValue(51,53,row)).toString());
		arg = new String []{"未检查","已检查"};
		matchCheck(54,row,map,"xspic0004g103","xspic0004g1",arg);
		if(StringUtils.isBlank((String)map.get("Pub13x00003"))) {
			map.put("xs00090", "复查提醒");
		}

	}

	public static void fillAataractMiddle(Map<String,Object> map,Object row) {
		//裸眼视力
		map.put("xs00095", net.sf.json.JSONArray.fromObject(getValue(11,13,row)).toString());
		//矫正视力
		map.put("xs00109", net.sf.json.JSONArray.fromObject(getValue(18,20,row)).toString());
		//眼轴(mm)
		map.put("xs00105", net.sf.json.JSONArray.fromObject(getValue(26,28,row)).toString());
		//综合验光
		map.put("xs00107", net.sf.json.JSONArray.fromObject(getValue(29,31,row)).toString());
	}


	public static void fillAataractAfter(Map<String,Object> map,Object row) {
		//裸眼视力
		map.put("xs00120", net.sf.json.JSONArray.fromObject(getValue(6,8,row)).toString());
		//矫正视力
		map.put("xs00121", net.sf.json.JSONArray.fromObject(getValue(8,10,row)).toString());
		//眼轴(mm)
		map.put("xs00122", net.sf.json.JSONArray.fromObject(getValue(10,12,row)).toString());
		//综合验光
		map.put("xs00123", net.sf.json.JSONArray.fromObject(getValue(12,14,row)).toString());
		//右眼屈光
		map.put("xs00124", net.sf.json.JSONArray.fromObject(getValue(14,17,row)).toString());
		//左眼屈光
		map.put("xs00125", net.sf.json.JSONArray.fromObject(getValue(17,20,row)).toString());
		//三棱镜度数(°)
		map.put("xs00127", net.sf.json.JSONArray.fromObject(getValue(20,22,row)).toString());
		//眼球运动
		map.put("xs00128", net.sf.json.JSONArray.fromObject(getValue(22,24,row)).toString());
		//眼部其他情况
		map.put("xs00129", net.sf.json.JSONArray.fromObject(match("",24,row,"")).toString());
		String [] arg = {"未检查","已检查"};
		matchCheck(33,row,map,"xspic00013g105","xspic00013g1",arg);
		arg = new String []{"未检查","阳性"};
		matchCheck(33,row,map,"xs00154g1","xs00153g1",arg);
		//角膜映光法（裸眼）
		map.put("xs00135", net.sf.json.JSONArray.fromObject(getValue(37,39,row)).toString());
		//角膜映光法(戴镜)
		map.put("xs00136", net.sf.json.JSONArray.fromObject(getValue(39,41,row)).toString());
		//三棱镜交替遮盖法(裸眼)
		map.put("xs00137", net.sf.json.JSONArray.fromObject(getValue(41,43,row)).toString());
		//三棱镜交替遮盖法(戴镜)
		map.put("xs00138", net.sf.json.JSONArray.fromObject(getValue(43,45,row)).toString());
		//三棱镜遮盖去遮盖法(裸眼)
		map.put("xs00139", net.sf.json.JSONArray.fromObject(getValue(45,47,row)).toString());
		//三棱镜遮盖去遮盖法(戴镜)
		map.put("xs00140", net.sf.json.JSONArray.fromObject(getValue(47,49,row)).toString());
		//三棱镜角膜映光法(裸眼)
		map.put("xs00141", net.sf.json.JSONArray.fromObject(getValue(49,51,row)).toString());
		//三棱镜角膜映光法(戴镜)
		map.put("xs00142", net.sf.json.JSONArray.fromObject(getValue(51,53,row)).toString());
		arg = new String []{"未检查","已检查"};
		matchCheck(54,row,map,"xspic0004g203","xspic0004g2",arg);

		match(map,"xs00144g102","xs00144g1","");
		match(map,"xs00145g102","xs00145g1","");
		match(map,"xs00146g103","xs00146g1","");
		match(map,"xs00147g103","xs00147g1","");

		if(StringUtils.isBlank((String)map.get("Pub13x00003"))) {
			map.put("xs00163", "复查提醒");
		}

	}


	//白内障手术前
	public static void fillAataractbnzBefore(Map<String,Object> map,Object row) {
		//裸眼视力
		map.put("ttbnz00030g1", net.sf.json.JSONArray.fromObject(getValue(7,9,row)).toString());
		//矫正视力
		map.put("ttbnz00030", net.sf.json.JSONArray.fromObject(getValue(9,11,row)).toString());
		if(row instanceof HSSFRow) {
			map.put("ttbnz00032g1", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(12)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00032g1", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(12)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz00033g1", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(15)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00033g1", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(15)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz00034", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(16)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00034", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(16)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz00039g1", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(19)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00039g1", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(19)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz00040g1", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(22)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00040g1", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(22)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz00041g101", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(23)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00041g101", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(23)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz00056", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(26)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00056", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(26)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz00061", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(29)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00061", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(29)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz00042", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(39)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00042", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(39)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz00072g1", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(32)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00072g1", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(32)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz00068", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(36)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00068", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(36)))).toString());
		}

	}

	public static void fillAataractbnzMiddle(Map<String,Object> map,Object row) {

		if(row instanceof HSSFRow) {
			map.put("xtbnz00095g1", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(12)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("xtbnz00095g1", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(12)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("xtbnz00096g1", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(15)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("xtbnz00096g1", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(15)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("xtbnz00097g1", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(18)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("xtbnz00097g1", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(18)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("xtbnz00098g1", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(21)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("xtbnz00098g1", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(21)))).toString());
		}

		if(row instanceof HSSFRow) {
			map.put("xtbnz00125g2", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(53)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("xtbnz00125g2", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(53)))).toString());
		}

		if(row instanceof HSSFRow) {
			map.put("xtbnz00125g1", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(35)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("xtbnz00125g1", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(35)))).toString());
		}
		//左眼K1
		map.put("xtbnz00103", net.sf.json.JSONArray.fromObject(getValue(27,29,row)).toString());
		//K1
		map.put("xtbnz00104", net.sf.json.JSONArray.fromObject(getValue(29,31,row)).toString());
		//K2
		map.put("xtbnz00105", net.sf.json.JSONArray.fromObject(getValue(31,33,row)).toString());
		//K2
		map.put("xtbnz00106", net.sf.json.JSONArray.fromObject(getValue(33,35,row)).toString());
		//眼轴长度
		map.put("xtbnz00117g1", net.sf.json.JSONArray.fromObject(getValue(36,39,row)).toString());
		//IOL(D)
		map.put("xtbnz00121g1", net.sf.json.JSONArray.fromObject(getValue(41,43,row)).toString());
		//预留屈光度(D)
		map.put("xtbnz00122g1", net.sf.json.JSONArray.fromObject(getValue(43,45,row)).toString());

		//右眼K1
		map.put("xtbnz00107", net.sf.json.JSONArray.fromObject(getValue(45,47,row)).toString());
		//K1
		map.put("xtbnz00108", net.sf.json.JSONArray.fromObject(getValue(47,49,row)).toString());
		//K2
		map.put("xtbnz00109", net.sf.json.JSONArray.fromObject(getValue(49,51,row)).toString());
		//K2
		map.put("xtbnz00110", net.sf.json.JSONArray.fromObject(getValue(51,53,row)).toString());
		//眼轴长度
		map.put("xtbnz00117g2", net.sf.json.JSONArray.fromObject(getValue(54,56,row)).toString());
		//IOL(D)
		map.put("xtbnz00121g2", net.sf.json.JSONArray.fromObject(getValue(59,61,row)).toString());
		//预留屈光度(D)
		map.put("xtbnz00122g2", net.sf.json.JSONArray.fromObject(getValue(61,63,row)).toString());
	}


	public static void fillAataractbnzAfter(Map<String,Object> map,Object row) {
		//裸眼视力
		map.put("ttbnz00140g1", net.sf.json.JSONArray.fromObject(getValue(6,8,row)).toString());
		//矫正视力
		map.put("ttbnz00151g2", net.sf.json.JSONArray.fromObject(getValue(8,10,row)).toString());
		if(row instanceof HSSFRow) {
			map.put("ttbnz00140", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(10)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00140", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(10)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz00148g1", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(14)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00148g1", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(14)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz00152g2", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(13)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00152g2", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(13)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz00153", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(17)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00153", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(17)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz00158", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(20)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00158", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(20)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz00167", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(23)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00167", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(23)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz00172", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(26)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00172", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(26)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz000173", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(27)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz000173", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(27)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz00174", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(28)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00174", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(28)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz00213", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(38)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00213", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(38)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz000187", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(53)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz000187", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(53)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz000188", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(54)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz000188", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(54)))).toString());
		}
		if(row instanceof HSSFRow) {
			map.put("ttbnz00194", net.sf.json.JSONArray.fromObject(dealList(dealWithHSSF(((HSSFRow) row).getCell(55)))).toString());
		}else if(row instanceof XSSFRow) {
			map.put("ttbnz00194", net.sf.json.JSONArray.fromObject(dealList(dealWithXSSF(((XSSFRow) row).getCell(55)))).toString());
		}
		//
		map.put("ttbnz00198", net.sf.json.JSONArray.fromObject(getValue(58,61,row)).toString());
		//
		map.put("ttbnz00199", net.sf.json.JSONArray.fromObject(getValue(61,64,row)).toString());
		//
		map.put("ttbnz00200", net.sf.json.JSONArray.fromObject(getValue(64,66,row)).toString());

	}


	//处理循环取值问题
	public static List<String> getValue (int begin,int end,Object obj){
		List<String> list = new ArrayList<String>();
		if(obj instanceof HSSFRow) {
			for(int i=begin;i<end;i++) {
				String value = dealWithHSSF(((HSSFRow) obj).getCell(i));
				if(StringUtils.isBlank(value)) {
					list.add("");
				}else {
					list.add(value);
				}
			}
		}else if(obj instanceof XSSFRow) {
			for(int i=begin;i<end;i++) {
				String value = dealWithXSSF(((XSSFRow) obj).getCell(i));
				if(StringUtils.isBlank(value)) {
					list.add("");
				}else {
					list.add(value);
				}
			}
		}
		return list;
	}


	//处理循环取值问题
	public static List<String> getValueOne (int begin,int end,Object obj){
		List<String> list = new ArrayList<String>();
		if(obj instanceof HSSFRow) {

			for(int i=begin;i<end;i++) {
				if(i==begin+1) {
					continue;
				}
				String value = dealWithHSSF(((HSSFRow) obj).getCell(i));
				if(StringUtils.isBlank(value)) {
					list.add("");
				}else {
					list.add(value);
				}
			}
		}else if(obj instanceof XSSFRow) {
			for(int i=begin;i<end;i++) {
				if(i==begin+1) {
					continue;
				}
				String value = dealWithXSSF(((XSSFRow) obj).getCell(i));

				if(StringUtils.isBlank(value)) {
					list.add("");
				}else {
					list.add(value);
				}
			}
		}
		return list;
	}

	//判断有无
	public static List<String> match (String optionId,int id,Object obj,String param){
		List<String> list = new ArrayList<String>();
		String value ="";
		if(obj instanceof HSSFRow) {
			value = dealWithHSSF(((HSSFRow) obj).getCell(id)).toString();
		}else if(obj instanceof XSSFRow) {
			value = dealWithXSSF(((XSSFRow) obj).getCell(id)).toString();
		}
		//判断遮盖有无
		if(StringUtils.isBlank(value) && StringUtils.isNotBlank(param)) {
			list.add("未知");
		}else if(StringUtils.isBlank(value)) {
			list.add("无");
		}else {
			list.add("有");
		}
		list.add(value);
		return list;
	}


	//判断有无
	public static void match (Map<String,Object> map,String id,String optionId,String param){
		//判断遮盖有无
		if(StringUtils.isBlank((String)map.get(id)) && StringUtils.isNotBlank(param)) {
			map.put(optionId, "未知");
		}else if(StringUtils.isBlank((String)map.get(id))) {
			map.put(optionId, "无");
		}else {
			map.put(optionId, "有");
		}

	}

	//处理数据
	public static List<String> dealList (String condition){
		List<String> list = new ArrayList<String>();
		String arg [] = null;
		if(StringUtils.isNotBlank(condition)) {
			if(condition.indexOf(" ")!=-1) {
				arg = condition.split(" ");
			}else if(condition.indexOf("，")!=-1) {
				arg = condition.split("，");
			}else if(condition.indexOf(",")!=-1) {
				arg = condition.split(",");
			}else if(condition.indexOf(";")!=-1) {
				arg = condition.split(";");
			}else if(condition.indexOf("；")!=-1) {
				arg = condition.split("；");
			}else if(condition.indexOf("*")!=-1) {
				arg = condition.split("*");
			}else {
				list.add(condition);
			}
			if(arg !=null  && arg.length>0) {
				for(int i=0;i<arg.length;i++) {
					list.add(arg[i]);
				}
			}
		}
		return list;
	}

	//亲属与患者关系特殊处理
	public static void matchList (int begin,int end,Object obj,Map<String,Object> map,String optionOne,String optionTwo){
		List<String> list = new ArrayList<String>();
		String arg [] = {"祖父母-父系","外祖父母-母系","父亲","母亲","兄弟姐妹","其他亲属"};
		boolean flag = false;
		int out = 0;
		if(obj instanceof HSSFRow) {
			for(int i=begin;i<end;i++) {
				String value = dealWithHSSF(((HSSFRow) obj).getCell(i));
				if(StringUtils.isBlank(value)) {
					list.add("");
				}else {
					list.add(arg[out]);
					flag = true;
				}
				if (i==(end-1)) {
					list.add(value);
				}
				out++;
			}
		}else if(obj instanceof XSSFRow) {
			for(int i=begin;i<end;i++) {
				String value = dealWithXSSF(((XSSFRow) obj).getCell(i));
				if(StringUtils.isBlank(value)) {
					list.add("");
				}else {
					list.add(arg[out]);
					flag = true;
				}
				if (i==(end-1)) {
					list.add(value);
				}
				out++;
			}
		}
		map.put(optionTwo,net.sf.json.JSONArray.fromObject(list).toString());
		//家族病史处理
		if(flag) {
			map.put(optionOne, "有");
		}else {
			map.put(optionOne, "未知");
		}
	}


	//判断是否检查
	public static void matchCheck (int id,Object obj,Map<String,Object> map,
			String optionOne,String optionTwo,String [] arg){
		String value ="";
		String out = "";
		if(obj instanceof HSSFRow) {
			value = dealWithHSSF(((HSSFRow) obj).getCell(id)).toString();
		}else if(obj instanceof XSSFRow) {
			value = dealWithXSSF(((XSSFRow) obj).getCell(id)).toString();
		}
		//判断遮盖有无
		if(StringUtils.isBlank(value)) {
			out = arg[0];
		}else {
			out = arg[1];
		}
		map.put(optionOne, value);
		map.put(optionTwo, out);
	}

	public static String checkQueue (String fileName) {
		String queueId ="";
		if(fileName.indexOf("斜视") !=-1) {
			queueId = "12gzeyequeue002";
		}else if(fileName.indexOf("白内障") !=-1){
			queueId = "12gzeyequeue003";
		}
		return queueId;
	}


	public static String NewArchive (Map<String,Object> map ,String fileName) {
		Map<String,Object> mapIn = new HashMap<String,Object>();
		List<Map<String,Object>> list = new ArrayList<Map<String,Object>> ();
		String queueId ="";
		if(fileName.indexOf("斜视") !=-1) {
			queueId = "12gzeyequeue002";
			mapIn.put("schemeId", "gzeyesch002");
			mapIn.put("schemeBusiType", 1);
			list.add(mapIn);
			map.put("followQueueId", "12gzeyequeue002");
			map.put("opCode", "1000");
			map.put("opNote", "批量眼科数据导入");
			map.put("opType", "2");
			map.put("sourceType", "2");
			map.put("userType", "1");
			map.put("schemeList", list);
		}else if(fileName.indexOf("白内障") !=-1){
			queueId = "12gzeyequeue003";
			mapIn.put("schemeId", "gzeyesch003");
			mapIn.put("schemeBusiType", 1);
			list.add(mapIn);
			map.put("followQueueId", "12gzeyequeue003");
			map.put("opCode", "1000");
			map.put("opNote", "批量眼科数据导入");
			map.put("opType", "2");
			map.put("sourceType", "2");
			map.put("userType", "1");
			map.put("schemeList", list);
		}
		return queueId;
	}


	public static String NewTask (Map<String,Object> map ,Map<String,Object> oprInfo ,String fileName,int count) {
		Map<String,Object> mapIn = new HashMap<String,Object>();
		oprInfo.put("opCode", "1001");
		oprInfo.put("opNote", "后端门诊诊疗录入");
		oprInfo.put("opType", "2");
		oprInfo.put("schemeBusiType", "1");
		String queueId ="";
		if(fileName.indexOf("斜视") !=-1) {
			oprInfo.put("followQueueId", "12gzeyequeue002");
			if(1==count) {
				mapIn.put("taskId", "10eyetask201");
				mapIn.put("ptTaskId", "");
			}else if(2==count) {
				mapIn.put("taskId", "10eyetask202");
				mapIn.put("ptTaskId", "");
			}else if(3==count) {
				mapIn.put("taskId", "10eyetask203");
				mapIn.put("ptTaskId", "");
			}

		}else if(fileName.indexOf("白内障") !=-1){
			oprInfo.put("followQueueId", "12gzeyequeue003");
			if(1==count) {
				mapIn.put("taskId", "10eyetask301");
				mapIn.put("ptTaskId", "");
			}else if(2==count) {
				mapIn.put("taskId", "10eyetask302");
				mapIn.put("ptTaskId", "");
			}else if(3==count) {
				mapIn.put("taskId", "10eyetask303");
				mapIn.put("ptTaskId", "");
			}
		}
		map.put("task", mapIn);
		return queueId;
	}


	public  void modifyMassage (Map<String, Object> argMap,Map<String, Object> sessionMap) throws Exception {
		JSONObject jsonData = new JSONObject(argMap);
		logger.info("modifyMassage  : "+jsonData);
		String currTime = jsonData.getString("opTime");// 入参中有操作时间，则使用入参中的时间
        if (StringUtils.isBlank(currTime)) {
            currTime = DateUtil.getTimeString(DateUtil.getSysDateA());// 创建时间
        }
        String updateAccept = SeqUtil.getSeqNo(Constants.SEQ_NO_FOR_SYSTEMID);// 操作流水

        // 参数校验后续补充
        String queueId = jsonData.getString("followQueueId");
        if (StringUtils.isBlank(queueId)) {
            throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参校验失败，未传入队列id或值为空！"));
        }
        Map<String, Object> map = new HashMap<String, Object>();
        Map<String, Object> chkMapIn = new HashMap<String, Object>();
        boolean isVerify = true;
        map.put("id", queueId);
        chkMapIn.put("queueId", queueId);
        FollowQueue queue = followQueueSerivce.getQueueDetailByQueueId(map);
        if (null == queue) {
            throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_QUEUE_NOT_EXIST, "根据队列id查询无此队列信息！"));
        }
        String queueUserType = queue.getQueueUsertype();

        Map<String, Object> servParamMap = jsonData;

        // 创建人，从session中获取
        String author = (String) sessionMap.get("authorId");
        String authorName = (String) sessionMap.get("authorName");// 登录账号医生姓名
        String tenantId = (String) sessionMap.get("tenantId");// 租户id
        String deptId = (String) sessionMap.get("deptId");

        String opCode = jsonData.getString("opCode");
        String opType = jsonData.getString("opType");
        if (StringUtils.isBlank(opCode)) {
            throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参校验失败，操作编码为空！"));
        }
        if (StringUtils.isBlank(opType)) {
            throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参校验失败，操作类型为空！"));
        }
        if (StringUtils.isBlank(jsonData.getString("opNote"))) {
            throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参校验失败，操作备注为空！"));
        }
        String userType = jsonData.getString("userType");
        if (Constants.QUEUE_USER_TYPE_PARTURIENT.equals(queueUserType)) {
            // 孕产妇（母亲），暂时写死，回头完善
            userType = "2";
        } else if (StringUtils.isBlank(userType)) {
            throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参校验失败，患者类型为空！"));
        }

        // 入参中没有，从问卷答案中获取
		Map<String, Object> quesMap = jsonData.getJSONObject("questiones");
        String phoneNum = jsonData.getString("phoneNum");
        if (StringUtils.isBlank(phoneNum) && MapUtils.isNotEmpty(quesMap)) {
            phoneNum = (String) quesMap.get(Constants.QUESTION_ID_FOR_PHONENO);
        }
        if (StringUtils.isBlank(phoneNum)) {
            phoneNum = "";
            chkMapIn.put("quesId", Constants.QUESTION_ID_FOR_PHONENO);
            isVerify = patientArchService.isVerifyArchiveParam(chkMapIn);
            if (isVerify) {
                throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "手机号码不能为空！"));
            }
        }
        phoneNum = phoneNum.trim();

        String patientName = jsonData.getString("patientName");
        if (StringUtils.isBlank(patientName) && MapUtils.isNotEmpty(quesMap)) {
            patientName = (String) quesMap.get(Constants.QUESTION_ID_FOR_PATIENTNAME);
        }
        if (StringUtils.isBlank(patientName)) {
            patientName = "";
            chkMapIn.put("quesId", Constants.QUESTION_ID_FOR_PATIENTNAME);
            isVerify = patientArchService.isVerifyArchiveParam(chkMapIn);
            if (isVerify) {
                throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "患者姓名不能为空！"));
            }
        }
        patientName = patientName.trim();

        String gender = jsonData.getString("gender");
        if (Constants.QUEUE_USER_TYPE_PARTURIENT.equals(queueUserType)) {
            // 孕产妇（母亲）
            gender = Constants.GENDER_FOR_FEMALE;
        } else if (StringUtils.isBlank(gender) && MapUtils.isNotEmpty(quesMap)) {
            gender = (String) quesMap.get(Constants.QUESTION_ID_FOR_GENDER);
        }
        if (StringUtils.isBlank(gender)) {
            gender = "";
            chkMapIn.put("quesId", Constants.QUESTION_ID_FOR_GENDER);
            isVerify = patientArchService.isVerifyArchiveParam(chkMapIn);
            if (isVerify) {
                throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "性别不能为空！"));
            }
        }
        gender = gender.trim();
        // 转换性别
        if (Constants.GENDER_ALIAS_FOR_MALE.equals(gender)) {
            gender = Constants.GENDER_FOR_MALE;
        } else if (Constants.GENDER_ALIAS_FOR_FEMALE.equals(gender)) {
            gender = Constants.GENDER_FOR_FEMALE;
        } else if (!Constants.GENDER_FOR_MALE.equals(gender) && !Constants.GENDER_FOR_FEMALE.equals(gender)) {
            gender = Constants.GENDER_FOR_MALE;
        }

        String birthday = jsonData.getString("birthday");
        if (StringUtils.isBlank(birthday) && MapUtils.isNotEmpty(quesMap)) {
            birthday = (String) quesMap.get(Constants.QUESTION_ID_FOR_BIRTHDAY);
        }
        if (StringUtils.isBlank(birthday) && !Constants.QUEUE_USER_TYPE_PARTURIENT.equals(queueUserType)) {
            birthday = null;
            chkMapIn.put("quesId", Constants.QUESTION_ID_FOR_BIRTHDAY);
            isVerify = patientArchService.isVerifyArchiveParam(chkMapIn);
            if (isVerify) {
                throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "出生日期不能为空！"));
            }
        }

        // 预产期
        String expectedDay = jsonData.getString("expectedDay");
        if (StringUtils.isBlank(expectedDay) && MapUtils.isNotEmpty(quesMap)) {
            expectedDay = (String) quesMap.get(Constants.QUESTION_ID_FOR_EXPECTEDDAY);
        }
        if (StringUtils.isEmpty(expectedDay)) {
            expectedDay = null;
        }

        // 出生胎龄(孕周)
        int pregnancyDay = 0;
        // 直接从入参中获取
        if (null !=jsonData.getInteger("pregnancyWeek")) {
            pregnancyDay = jsonData.getInteger("pregnancyWeek");
        }
        // 再考虑从问卷中获取，问卷存储格式：[39,5]
        if (pregnancyDay <= 0 && !MapUtils.isEmpty(quesMap)) {
            String preStr = (String) quesMap.get(Constants.QUESTION_ID_FOR_PREGNANCYDAY);
            if (!StringUtils.isBlank(preStr)) {
                String preArr[] = preStr.split(Constants.COMMA_SPLIT_STR);
                if (null != preArr && 2 == preArr.length) {
                    String preWeekStr = preArr[0].substring(1);
                    String preDayStr = preArr[1].substring(0, preArr[1].length() - 1);
                    int preWeek = Integer.parseInt(preWeekStr);
                    int preDay = Integer.parseInt(preDayStr);
                    pregnancyDay = preWeek * Constants.PREGNANCY_CALC_UNIT_WEEK + preDay;
                }
            }
        }
        // 最后根据根据生日和预产期计算
        if (Constants.QUEUE_USER_TYPE_PARTURIENT.equals(queueUserType)) {
            // 孕产妇（母亲）
            // 初检孕周
            String firstChkPregWeek = (String) quesMap.get(Constants.QUESTION_ID_FOR_PREGNANCY_FIRST_WEEK);
            if (StringUtils.isBlank(firstChkPregWeek)) {
                // 不在这里校验，在实例化随访任务时校验
            } else {
                servParamMap.put("firstChkPregWeek", Integer.parseInt(firstChkPregWeek));
            }
            // 末次月经日期
            String lastMenstruationDate = (String) quesMap.get(Constants.QUESTION_ID_FOR_LAST_MENSTRUATION_DATE);
            if (StringUtils.isBlank(lastMenstruationDate)) {
                // 不在这里校验，在实例化随访任务时校验
            } else {
                servParamMap.put("lastMenstruationDate", lastMenstruationDate);
            }
            // 分娩日期
            servParamMap.put("deliveryDate", quesMap.get(Constants.QUESTION_ID_FOR_LAST_DELIVERY_DATE));
        } else if (pregnancyDay <= 0 && !StringUtils.isBlank(expectedDay)) {
            pregnancyDay = ToolUtils.calPrenDayByBirthAndExpect(birthday, expectedDay);
        }

        // 孕周未填，默认280
        if (pregnancyDay <= 0) {
            pregnancyDay = Constants.PATIENT_NORMAL_PREGNANT_DAY;
        }
        // 预产期未填，默认与出生日期一致
        if (StringUtils.isBlank(expectedDay)) {
            expectedDay = birthday;
        }
        // 来源渠道
        String sourceType = jsonData.getString("sourceType");
        if (StringUtils.isBlank(sourceType)) {
            // 默认web端门诊渠道
            sourceType = Constants.PATIENT_SOURCE_TYPE_DOOR;
        }

        Patient pt = new Patient();
        pt.setPregnancyDay(pregnancyDay);
        pt.setUserName(patientName);
        pt.setPhoneNo(phoneNum);
        pt.setFirstName(patientName.substring(0, 1));
        pt.setCreateTime(currTime);
        pt.setUpdateTime(currTime);
        pt.setCreateAuthor(author);
        pt.setBirthday(birthday);
        pt.setExpectedDay(expectedDay);
        pt.setGender(gender);
        pt.setUserType(userType);
        pt.setSourceType(sourceType);

        servParamMap.put("patient", pt);
        servParamMap.put("authorName", authorName);
        servParamMap.put("deptId", deptId);
        servParamMap.put("queueId", queueId);
        servParamMap.put("updateTime", currTime);
        servParamMap.put("authorId", author);
        servParamMap.put("updateAccept", updateAccept);
        servParamMap.put("tenantId", tenantId);
        servParamMap.put("opCode", opCode);
        servParamMap.put("opNote", jsonData.getString("opNote"));
        servParamMap.put("opType", opType);
        servParamMap.put("contentData", jsonData.getJSONObject("questiones"));

        List<Map<String, Object>> schemeList = ToolUtils.typeCast(jsonData.getJSONArray("schemeList"));
        int shsize = schemeList.size();
        int sh = 0;
        Map<String, Object> schemeMap = new HashMap<String, Object>();
        Integer schemeBusiType = 0;
        String schemeId = "";
        // 如果有数据，则校验
        for (sh = 0; sh < shsize; sh++) {
            schemeMap = schemeList.get(sh);
            schemeBusiType = (Integer) schemeMap.get("schemeBusiType");
            if (null == schemeBusiType) {
                throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参校验失败，方案业务类型不能为空！");
            }
            schemeId = (String) schemeMap.get("schemeId");
            if (StringUtils.isBlank(schemeId)) {
                throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参校验失败，方案id不能为空！");
            }
        }
        logger.info("savePatientArchives:"+servParamMap);
       patientTreatService.savePatientArchives(servParamMap);
	}

	public  void modifyTask (Map<String, Object> argMap,Map<String, Object> sessionMap) throws Exception {
		JSONObject jsonData = new JSONObject(argMap);
		logger.info("modifyTask  : "+jsonData);
		JSONObject jsonTask = jsonData.getJSONObject("task");
        if (null == jsonTask) {
            // 前台必须传task节点，否则报错返回
            throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无task节点！"));
        }
        JSONObject jsonOpInfo = jsonData.getJSONObject("oprInfo");
        if (null == jsonOpInfo) {
            throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无oprInfo节点！"));
        }
        // 方案业务类型
        String schemeBusiType = jsonOpInfo.getString("schemeBusiType");
        if (StringUtils.isBlank(schemeBusiType)) {
            throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，未传入方案类型或值为空！"));
        }
        int schemeBusiTypes = Integer.parseInt(schemeBusiType);

        String opCode = jsonOpInfo.getString("opCode");
        if (StringUtils.isBlank(opCode)) {
            throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无操作编码节点！"));
        }
        String queueId = jsonOpInfo.getString("followQueueId");
        if (StringUtils.isBlank(queueId)) {
            throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，无队列id节点！"));
        }
        String ptSchemeId = jsonOpInfo.getString("ptSchemeId");
        if (StringUtils.isBlank(ptSchemeId)) {
            throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,
                    "入参节点错误，未传入患者队列实例id或值为空！"));
        }
        String userId = jsonOpInfo.getString("patientId");
        if (null == userId || "".equals(userId)) {
            throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "入参节点错误，患者id未传或值为空！"));
        }

        HashMap<String, Object> paramMap = new HashMap<String, Object>();
        // 创建人，从session中获取
        String author = (String) sessionMap.get("authorId");
        String authorName = (String) sessionMap.get("authorName");// 登录账号医生姓名
        String tenantId = "";
        String deptId = (String) sessionMap.get("deptId");// 租户id
        paramMap.put("authorName", authorName);
        // 修改手机号同步app 使用
        paramMap.put("deptId", deptId);

        String taskId = jsonTask.getString("ptTaskId");
        String task = jsonTask.getString("taskId");
        if (StringUtils.isBlank(task) && StringUtils.isBlank(task)) {
            throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,
                    "入参节点错误，未传入患者任务id或值为空！"));
        }
        String seqNo = jsonTask.getString("seqNo");
        boolean initTask = false;// 建档任务
        if (!StringUtils.isEmpty(seqNo)) {
            if (seqNo.equals("" + Constants.TASK_SEQ_FOR_INIT)) {
                initTask = true;
            }
        }

        String finishDate = jsonTask.getString("finishDate");
        if (schemeBusiTypes == Constants.SCHEME_BUSI_TYPE_0) {
            if (!initTask && StringUtils.isBlank(finishDate)) {
                // 建档可以不传随访日期
                throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "未传入随访日期或值为空！"));
            }
        }
        String updateAuname = jsonTask.getString("updateAuname");
        if (StringUtils.isBlank(updateAuname)) {
            updateAuname = authorName;
        }

        JSONArray ptContentIds = jsonTask.getJSONArray("ptContentIds");
        if (schemeBusiTypes == Constants.SCHEME_BUSI_TYPE_0) {
            if (null == ptContentIds || 0 == ptContentIds.size()) {
                throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,
                        "入参节点错误，未传入患者任务内容id节点或值为空！"));
            }
        }
        Map<String, Object> quesMap = jsonData.getJSONObject("questiones");
        if (MapUtils.isEmpty(quesMap)) {
            throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR,
                    "入参节点错误，未传入任务内容报文或值为空！"));
        }
        // 生物样本采集信息（安医大需求）
        JSONArray sampleList = jsonData.getJSONArray("sampleList");
        if (null != sampleList) {
            paramMap.put("sampleList", sampleList);
        }

        String currTime = jsonOpInfo.getString("opTime");// 入参中有操作时间，则使用入参中的时间
        if (StringUtils.isBlank(currTime)) {
            currTime = DateUtil.getTimeString(DateUtil.getSysDateA());// 创建时间
        }
        // 来源渠道
        String sourceType = jsonOpInfo.getString("sourceType");
        if (StringUtils.isBlank(sourceType)) {
            // 默认web端门诊渠道
            sourceType = Constants.PATIENT_SOURCE_TYPE_DOOR;
        }
        paramMap.put("sourceType", sourceType);

        String updateAccept = SeqUtil.getSeqNo(Constants.SEQ_NO_FOR_SYSTEMID);// 操作流水
        paramMap.put("taskId", taskId);// 任务实例id
        paramMap.put("task", task);// 任务id
        paramMap.put("contentData", quesMap);
        paramMap.put("ptSchemeId", ptSchemeId);// 患者方案id
        paramMap.put("userId", userId);
        paramMap.put("updateTime", currTime);
        paramMap.put("updateAccept", updateAccept);
        paramMap.put("authorId", author);
        paramMap.put("tenantId", tenantId);
        paramMap.put("opCode", opCode);
        paramMap.put("queueId", queueId);
        paramMap.put("opNote", jsonOpInfo.getString("opNote"));
        paramMap.put("opType", jsonOpInfo.getString("opType"));
        paramMap.put("ptContentIds", ptContentIds);
        paramMap.put("updateAuname", updateAuname);
        paramMap.put("finishDate", finishDate);

        String taskNote = jsonTask.getString("taskNote");
        if (StringUtils.isBlank(taskNote)) {
            taskNote = (String) quesMap.get(Constants.QUESTION_ID_FOR_TR_TASK_CHECK_NOTE);
        }
        String nextDate = jsonTask.getString("nextDate");
        if (StringUtils.isBlank(nextDate)) {
            nextDate = (String) quesMap.get(Constants.QUESTION_ID_FOR_TR_TASK_NEXT_CHECK_DATE);
        }
        String nextAddress = jsonTask.getString("nextAddress");
        if (StringUtils.isBlank(nextAddress)) {
            nextAddress = (String) quesMap.get(Constants.QUESTION_ID_FOR_TR_TASK_NEXT_CHECK_ADDRESS);
        }
        paramMap.put("taskNote", taskNote);
        paramMap.put("nextDate", nextDate);
        paramMap.put("nextAddress", nextAddress);

        // 问卷类型，这里先写死0代表门诊问卷
        paramMap.put("type", Constants.QUESTIONNAIRE_TYPE_0);
        logger.info("submitTaskFunciton:"+paramMap);
        if (schemeBusiTypes == Constants.SCHEME_BUSI_TYPE_0) {
            patientSerivce.modTaskContentData(paramMap);
        } else if (schemeBusiTypes == Constants.SCHEME_BUSI_TYPE_1) {
            ptTaskTreatService.submitTaskFunciton(paramMap);
        } else {
            throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_INPUT_DATA_VERIFY_ERROR, "暂不支持此方案业务类型！");
        }
	}

}
